import pymysql


def main():
    conn = pymysql.connect(
        host='127.0.0.1',
        port=3306,
        user='root',
        db='test',
        password='123456'
    )
    sql = '''
    INSERT INTO A VALUES('4','4','4','4')
    '''

    try:
        with conn.cursor() as cursor:
            cursor.execute(sql)
            conn.commit()
        print(conn)
    except pymysql.MySQLError as error:
        print(error)
        conn.rollback()
    finally:
        conn.close()



if __name__ == '__main__':
    main()
